use oso_live::*;

fn main() {
    let perm = Permission::<User, RepositoryRole, Repository>::try_new().unwrap();
    let mut user = User::new("tom");
    let repo = Repository::new("github", false);
    user.add_role("reader", &repo.name);
    println!("user tom have read access: {}", perm.is_allowed(user.clone(), "read", repo.clone()).unwrap());
    println!("user tom have write access: {}", perm.is_allowed(user.clone(), "write", repo.clone()).unwrap());

    let mut admin = User::new("admin");
    admin.add_role("admin", &repo.name);
    println!("user admin have read access: {}", perm.is_allowed(admin.clone(), "read", repo.clone()).unwrap());
    println!("user admin have write access: {}", perm.is_allowed(admin.clone(), "write", repo.clone()).unwrap());
    println!("user admin have delete access: {}", perm.is_allowed(admin.clone(), "delete", repo.clone()).unwrap());
}
